package com.bzyd.derby;

import com.bzyd.derby.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;

@Slf4j
@SpringBootApplication
@MapperScan("com.bzyd.derby.mapper")
public class DerbyApplication {

    public static void main(String[] args) {
        SpringApplication.run(DerbyApplication.class, args);
    }

    @Autowired
    private UserMapper userMapper;

    @PostConstruct
    public void init(){
        try {
            userMapper.checkUserExist();
        } catch (Exception e) {
            userMapper.createUserTable();
            log.info("初始化用户表成功");
        }
    }

//    @PostConstruct
//    public void init(){
//        try {
//            userMapper.createUserTable();
//            log.info("初始化用户表成功");
//        } catch (Exception ignored) {
//
//        }
//    }


}
